<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ include file="/common/base.jsp"%>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>主页</title>
<link rel="stylesheet"
	href="${ctx}/styles/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${ctx}/styles/bootstrap/css/bootstrap-table.css">
<link rel="stylesheet" href="${ctx}/styles/main.css">
</head>

<body>
	<nav class="navbar navbar-default navbar-static-top">
		<div class="container">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed"
					data-toggle="collapse" data-target="#paisong-index-nav-menu"
					aria-expanded="false">
					<span class="sr-only">Toggle navigation</span> <span
						class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="#">派送CMS</a>
			</div>
			<!-- Collect the nav links, forms, and other content for toggling -->
			<div class="collapse navbar-collapse" id="paisong-nav-menu">
				<ul class="nav navbar-nav" id="paisong-nav-menu-main">
					<li class="dropdown"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown" role="button" aria-haspopup="true"
						aria-expanded="false">员工管理<span class="caret"></span></a>
						<ul class="dropdown-menu">
							<li class="active"><a href="#" data-url="${ctx}/staff/list">员工信息管理</a></li>
							<li><a href="#" data-url="${ctx}/staff/pos/list">员工位置信息（表格）</a></li>
							<li><a href="#" data-url="${ctx}/staff/pos/map">员工位置信息（地图）</a></li>
						</ul></li>
				</ul>
				<ul class="nav navbar-nav navbar-right">
					<li class="dropdown"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown" role="button" aria-haspopup="true"
						aria-expanded="false">你好：${session.nickname}<span
							class="caret"></span></a>
						<ul class="dropdown-menu">
							<li><a href="#" id="a_change_pd">修改密码</a></li>
							<li role="separator" class="divider"></li>
							<li><a href="#" id="a_logout">退出登录</a></li>
						</ul></li>
				</ul>
			</div>
			<!-- /.navbar-collapse -->
		</div>
	</nav>
	<!-- 公共模态对话框 -->
	<div class="modal fade" id="publicModal" tabindex="-1" role="dialog"
		aria-labelledby="publicModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="publicModalLabel">提醒</h4>
				</div>
				<div class="modal-body">
					<p>...</p>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					<button type="button" class="btn btn-info" data-dismiss="modal">确定</button>
				</div>
			</div>
		</div>
	</div>
	<div id="con" class="container"></div>
	<script src="${ctx}/scripts/jquery/jquery-1.11.3.min.js"></script>
	<script src="${ctx}/scripts/bootstrap/bootstrap.min.js"></script>
	<script src="${ctx}/scripts/bootstrap/bootstrap-table.js"></script>
	<script src="${ctx}/scripts/bootstrap/bootstrap-table-zh-CN.min.js"></script>
	<script src="${ctx}/scripts/jquery/jquery.blockUI.js"></script>
	<script src="${ctx}/scripts/util.js"></script>
	<script>
		var now_active = $("li.active");
		$(document).ready(function() {
			var liArr = $("#paisong-nav-menu-main>li");
			liArr.each(function(i, content) {
				var ul = $(this).find("ul");
				if (ul.length) {
					ul.each(function() {
						$(this).find("a").click(function() {
							pageContentLoad(this);
						});
					})
				} else {
					$(this).find("a").click(function() {
						pageContentLoad(this)
					});
				}
			});

			$("#a_change_pd").click(function() {

			});

			$("#a_logout").click(function() {
				$.ajax({
					type : "POST",
					url : "${ctx}/logout",
					dataType : "json",
					success : function() {
						window.location.replace("${ctx}/login");
					}
				});
			});

			pageContentLoad(now_active.find("a"));

		})

		var divContent = $("div#con");

		function pageContentLoad(alink) {
			if (now_active != $(alink).parent()) {
				now_active.removeClass("active");
				now_active = $(alink).parent();
				now_active.addClass("active");
				$.ajax({
					type : "GET",
					url : $(alink).data("url"),
					dataType : "text",
					success : function(data) {
						divContent.html(data);
					}
				});
			}
		}
	</script>
</body>

</html>
